using System;
using mojoPortal.Web.Framework;
using mojoPortal.Web;
using System.Collections;
using mojoPortal.Business;

namespace ud_SwirlingQuestion
{

    public partial class ViewAnswerPage : mojoBasePage
    {
        private int moduleId = -1;
        SwirlingQuestionConfiguration config = new SwirlingQuestionConfiguration();

        #region OnInit

        protected override void OnPreInit(EventArgs e)
        {
            AllowSkinOverride = true;
            base.OnPreInit(e);
        }

        override protected void OnInit(EventArgs e)
        {
            Load += Page_Load;
            LoadPanels();
            base.OnInit(e);
        }

        private void LoadPanels()
        {
            moduleId = WebUtils.ParseInt32FromQueryString("mid", moduleId);
            Hashtable settings = ModuleSettings.GetModuleSettings(moduleId);
            config = new SwirlingQuestionConfiguration(settings);
            LoadSideContent(config.ShowLeftPanelSetting, config.ShowRightPanelSetting, config.ShowTopPanelSetting,
                            config.ShowBottomPanelSetting, config.ShowNumberModuleSetting);
        }
        
        #endregion

        private void Page_Load(object sender, EventArgs e)
        {
            LoadSettings();
            PopulateLabels();
        }

        private void PopulateLabels()
        {
        }

        private void LoadSettings()
        {
            moduleId = WebUtils.ParseInt32FromQueryString("mid", -1);
        }

        protected override void OnError(EventArgs e)
        {
            Exception lastError = Server.GetLastError();
            if ((lastError == null) || (!(lastError is NullReferenceException)) || !Page.IsPostBack) return;
            if (!lastError.StackTrace.Contains("Recaptcha")) return;
            Server.ClearError();
            WebUtils.SetupRedirect(this, Request.RawUrl);
        }
    }
}
